package cis350.pcr.types;

import java.util.HashMap;
import java.util.LinkedHashMap;

import cis350.pcr.types.Item;
import cis350.pcr.types.Type.RatingType;

/*
 * Ratings are given to each item and contain a description of the Professor
 * or Course
 */
public class Semester extends Item implements Comparable{
	public String comments;
	//this comes with the JSON string
	public String id;
	//Map from metric to score (ie Difficulty:3.1)
	public String num_students;
	public String num_reviewers;
	
	public LinkedHashMap<RatingType, Double> scores;

	public Semester() {
		comments = "";
		scores = new LinkedHashMap<RatingType, Double>();
		id = "";
		num_students = "";
		num_reviewers = "";
	}

	public Double get(RatingType type) {
		return scores.get(type);
	}
	
	@Override
	public String getRowText() {
		String sem = "", year;
		if (id.contains("A"))
			sem = "Spring";
		else if (id.contains("B"))
			sem = "Summer";
		else if (id.contains("C"))
			sem = "Fall";
		year = id.substring(0, 4);
		
		return sem + " " + year;
	}

	@Override
	public String getRowSubtext(boolean b) {
		return num_reviewers + "/" + num_students + " responses"; 
	}

	@Override
	public String getActionBarTitle() {
		return "";
	}
	@Override
	public String getInfo() {
		return "";
	}
	

	public int compareTo(Object another) {
		if (another instanceof Semester)
			return ((Semester)another).id.compareTo(this.id);
		return 0;
	}
}